import { Injectable } from '@angular/core';
import { environment } from '../../../environments/environment';
// 如果需要，写入sessionstorage
@Injectable()
export class ConfigService {
  private properties: any;
  constructor() {
    this.properties = environment;
  }
  public get(key: string): any {
    const a = this.properties;
    const l = key.indexOf('.');
    if (l > 0) {
      return this.getRecursion(key.substr(l + 1), a[key.substr(0, l)]);
    }
    return this.properties[key];
  }
  private getRecursion(key: string, p: any) {
    const l = key.indexOf('.');
    if (l > 0) {
      return this.getRecursion(key.substr(l + 1), p[key.substr(0, l)]);
    }
    return p[key];
  }
}
